package org.example.InterfaceDemo;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class UsermanagerImpl1Proxy implements InvocationHandler {

    private Object objectClass;

    public Object newProxyInstance(Object objectClass) {
        this.objectClass=objectClass;
        System.out.println("objectClass.getClass().getClassLoader()"+objectClass.getClass().getClassLoader().toString());
        System.out.println("objectClass.getClass().getInterfaces()"+objectClass.getClass().getInterfaces().toString());
        System.out.println("this"+this);
        return Proxy.newProxyInstance(objectClass.getClass().getClassLoader(),objectClass.getClass().getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("start======");
        Object ret = null;
        try{
            ret = method.invoke(objectClass,args);
            System.out.println("end======");
        }catch (Exception e){

        }
        return ret;
    }
}
